﻿using System;
using System.Linq;

namespace Mss.Data.Repositories.Users
{
    internal class UsersRepository : Repository<User>, IUsersRepository
    {
        public User LogOn(string userName, string password)
        {
            if (CachedObjects == null)
            {
                Load();
            }

            User resultUser = null;
            if (CachedObjects != null)
            {
                resultUser = CachedObjects.Where(user => user.UserName == userName && user.Password == password).SingleOrDefault();
            }
            
            return resultUser;
        }
    }
}